<script setup>
import { ref } from 'vue';
import dayjs from 'dayjs';

const { config } = defineProps({
  config: {
    type: Object,
    required: true,
  }
});
const emits = defineEmits(['change']);

const data = ref(config.value || '');
const defaultTime = dayjs(dayjs().format('YYYY-MM-DD ') + config.defaultTime).toDate();

const handleChange = (value) => {
  emits('change', value);
}
</script>

<template>
  <el-date-picker
    v-model="data"
    type="datetime"
    placeholder="请选择日期和时间"
    format="YYYY-MM-DD HH:mm:ss"
    value-format="YYYY-MM-DD HH:mm:ss"
    :default-value="defaultTime"
    :default-time="defaultTime"
    @change="handleChange"
  />
</template>

<style lang="scss" scoped>

</style>